package cn.goodym.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.goodym.mapper.CasesTestMapper;
import cn.goodym.po.CasePort;
import cn.goodym.po.CasesTest;
import cn.goodym.po.PagingVO;
import cn.goodym.service.CasesTestService;

@Service("casesTestService")
public class CasesTestServiceImpl implements CasesTestService {

	@Autowired
	private CasesTestMapper casesTestMapper;

	@Override
	public Boolean save(CasesTest casesTest) {
		CasesTest cTest = casesTestMapper.selectByPrimaryKey(casesTest.getId());
		if (cTest == null) {
			casesTestMapper.insert(casesTest);
			return true;
		}
		return false;
	}

	public int getCount() {
		return casesTestMapper.countByExample();
	}

	@Override
	public List<CasesTest> findByPaging(Integer toPageNo) {
		PagingVO pagingVO = new PagingVO();
		pagingVO.setToPageNo(toPageNo);
		List<CasesTest> list = casesTestMapper.findByPaging(pagingVO);
		return list;
	}

	public void removeById(Integer id) {
		casesTestMapper.deleteByPrimaryKey(id);
	}

	@Override
	public CasesTest findById(Integer id) {
		return casesTestMapper.selectByPrimaryKey(id);
	}

	@Override
	public void updateById(CasesTest casesTest) {
		casesTestMapper.updateByPrimaryKey(casesTest);
	}

	@Override
	public List<CasesTest> findByName(String name) {
		List<CasesTest> list = casesTestMapper.selectByExample(name);
		return list;
	}

	@Override
	public CasesTest findByPortId(Integer portId) {
		return casesTestMapper.selectByportId(portId);
	}


}
